<template>
	<view class="product-item u-border-bottom" @click="handleClick">
		<image :src="img" mode="aspectFill" class="product-img"></image>
		<view class="product-info">
			<text class="name u-line-2">{{name}}</text>
			<text class="manufactor">厂家：{{manufactor}}</text>
			<view class="summary">
				<view class="views" v-if="showViews">
					<image src="../../static/imgs/icon-views.png" mode="scaleToFill"></image>
					<text class="label">浏览：</text>
					<text>{{views}}</text>
				</view>
				<view class="booth" v-if="showBooth">
					<image src="../../static/imgs/icon-booth.png" mode="scaleToFill"></image>
					<text class="label">展位：</text>
					<text v-if="booth.length > 0" v-for="(item, index) in booth" :key="item.booth_id" >{{ index === (booth.length - 1) ? item.booth_no: item.booth_no + '、' }}</text>
					<text v-if="booth.length <= 0">暂无</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"ProductItem",
		props: {
			productId: {
				type: Number
			},
			
			img: {
				type: String
			},
			
			name: {
				type: String
			},
			
			manufactor: {
				type: String
			},
			
			views: {
				type: Number
			},
			
			// 展位列表集合
			booth: {
				type: Array,
				default: function() {
					return []
				}
			},
			
			// 是否显示展位信息
			showBooth: {
				type: Boolean,
				default: true
			},
			
			// 是否展示浏览量
			showViews: {
				type: Boolean,
				default: true
			}
		},
		data() {
			return {
				
			};
		},
		methods: {
			handleClick() {
				this.$emit('detail', this.productId)
			}
		}
	}
</script>

<style scoped lang="scss">
.product-item{
	display: flex;
	align-items: center;
	padding: 36rpx 0;
	.product-img{
		margin-left: 10rpx;
		margin-right: 20rpx;
		flex-shrink: 0;
		width: 180rpx;
		height: 180rpx;
		box-shadow: 2px 2px 5px 0 rgba($color: #000000, $alpha: .4);
	}
	
	.product-info{
		height: 180rpx;
		display: flex;
		flex-direction: column;
		.name{
			// font-size: 18px;
			font-size: 36rpx;
			font-weight: bold;
			color: #303133;
		}
		
		.manufactor {
			margin-top: 6rpx;
			font-size: 12px;
			color: #A2A2A2;
		}
		
		.summary{
			margin-top: auto;
			display: flex;
			align-items: center;
			&>view{
				margin-right: 26rpx;
			}
			.views{
				display: flex;
				align-items: center;
				image{
					margin-right: 6rpx;
					width: 30rpx;
					height: 30rpx;
				}
				
				text{
					font-size: 12px;
					color: #EB5D3E;
					
					&.label{
						color: #A2A2A2;
					}
				}
			}
			
			.booth{
				display: flex;
				align-items: center;
				image{
					margin-right: 6rpx;
					width: 24rpx;
					height: 24rpx;
				}
				
				text{
					font-size: 12px;
					color: #EB5D3E;
					
					&.label{
						color: #A2A2A2;
					}
				}
			}
		}
	}
}
</style>
